'use strict';
const {
  Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class Comment extends Model {
    /**
     * Helper method for defining associations.
     * This method is not a part of Sequelize lifecycle.
     * The `models/index` file will call this method automatically.
     */
    static associate(models) {
        //一条评论属于某一个用户
        models.Comment.belongsTo(models.User,{
          foreignKey: {
            name: 'user_id'
          }
        })
    }
  }
  Comment.init({
    content: DataTypes.STRING,
    user_id: DataTypes.INTEGER,
    news_id: DataTypes.INTEGER,
    is_del: DataTypes.INTEGER,
    com_time: DataTypes.DATE
  }, {
    sequelize,
    modelName: 'Comment',
    timestamps:false
  });
  return Comment;
};